package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.ButtonGroup;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;

import user.User;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JButton;

public class StudentRegComp extends JFrame {

	private JPanel contentPane;
	private User currUser;
	private JPanel panel;
	private JPanel panel_1;
	private JLabel registeredLabel;
	private JPanel panel_2;
	private JButton homeBttn;
	private JPanel ccPanel;
	private JPanel tPanel;
	private JPanel sPanel;
	private JPanel mPanel;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					StudentRegComp frame = new StudentRegComp(new User("stud1"));
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * @param currUser 
	 */
	public StudentRegComp(User currUser) {
		this.currUser = currUser;
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		panel_1 = new JPanel();
		contentPane.add(panel_1, BorderLayout.NORTH);
		
		registeredLabel = new JLabel("You have registered for the following courses: ");
		panel_1.add(registeredLabel);
		
		panel_2 = new JPanel();
		contentPane.add(panel_2, BorderLayout.SOUTH);
		
		homeBttn = new JButton("Go to Homepage");
		panel_2.add(homeBttn);
		homeBttn.addActionListener(nextListener);		
		
		
		JLabel form[][] = new JLabel[12][3];
	    String counts[] = { "Course Code", "Title", "Section", "Mode of Grading"};

	    JPanel p = new JPanel();
	    p.setSize(600, 400);
	    p.setLayout(new GridLayout(4, 4, 0, 0));
	    for (int row = 0; row < 4; row++) {
	     
	      for (int col = 0; col < 4; col++) {
	        if (row == 0) {
	          p.add(new JLabel(counts[col]));
	        } 
	        else {
		          if (col == 0) {
		        	
		          } 
		          else {
		            form[row - 1][col-1] = new JLabel("*");
		           
		            p.add(form[row - 1][col-1]);
		          }
	            
	          }
	        
	      }
	    }

	    contentPane.add(p, BorderLayout.CENTER);
		
		
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////
// BUTTON LISTENERS
///////////////////////////////////////////////////////////////////////////////////////////////////////

	private ActionListener nextListener = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			HomePageFrame regFrame = new HomePageFrame(currUser);
			regFrame.setVisible(true);
			StudentRegComp.this.dispose();
		}
	};
//------------------------------------------------------------------------------------------------
	
}
